<?php
// +--------------------------------------------------------------------------
// | ZAIYOUDAO [ 载攸道 先顺得常 ] <http://www.zaiyoudao.com>
// +--------------------------------------------------------------------------
// | Copyright © 2009-2016 载攸道 版权所有 <TEL:17090888854>
// +--------------------------------------------------------------------------
// | Project: YiPHP [ 我会的仅仅是偷懒！ ] <http://www.yiphp.com>
  // | Author: 牛很多戒很多不戒 <n@isdce.com> <http://juexue.wang>
// +--------------------------------------------------------------------------

/**
 * Music
 */
namespace Music\Controller;
use Music\Controller\PublicController;

/**
 *接口
 */
class PortController extends PublicController{
	/* 初始化 */
    protected function _initialize(){
		header('Access-Control-Allow-Origin:*');//允许所有来源访问
		header('Access-Control-Allow-Method:POST,GET');//允许访问的方式    
		header("content-Type: text/html; charset=Utf-8"); 
	}
	
	#微信小程序根据code获得openid
	public function get_openid(){
		$code = I("param.code");
		$url = "https://api.weixin.qq.com/sns/jscode2session?appid=wxc6cfe9e7f97b9edf&secret=a2dcc0753d8073450c1ca67c4d103cdf&grant_type=authorization_code&js_code=".$code;
		#$url = "https://api.weixin.qq.com/sns/jscode2session?appid=wxc6cfe9e7f97b9edf&secret=a2dcc0753d8073450c1ca67c4d103cdf&grant_type=authorization_code&js_code=081gsFa40l7SFC1LVl940yJIa40gsFaH";
		$result = file_get_contents($url);
		echo $result;
		
	}
	
	
	
	#播放记录
	public function recently(){
		
		$m_cms_recently = M("cms_recently");
		$m_mall_content = M("mall_content");
		$m_cms_collection = M("cms_collection");
		$m_cms_content_comments = M("cms_content_comments");
		if(IS_POST){
			$uid = I('param.uid');
			if($uid > 0){
				$map['uid'] = $uid;
				$map['type'] = 2;
				$map['status'] = 1;
				$list = $m_cms_recently->where($map)->field("r_id")->order("time desc")->select();
				
				foreach($list as $i=>$v){
					$music_map['id'] = $list[$i]['r_id'];
					$music_map['type'] = 15;
					$music_map['status'] = 1;
					$result = $m_mall_content->where($music_map)->field("name,mp3,id,singer,value,foil_img")->find();
					$result['foil_img'] = if_url($result['foil_img']);
					$result['ma3'] = if_url($result['mp3']);
					#是否喜欢
					$cc_mpoa['type'] = 1;
					$cc_mpoa['form_id'] = $list[$i]['r_id'];
					$cc_data = $m_cms_collection->where($cc_map)->find();
					if($cc_data){
						$result['if_like'] = 1;
					}else{
						$result['if_like'] = 0;
					}
					#评论数量
					$comments_map['form_id'] = $list[$i]['r_id'];
					$comments_map['type'] = 2;
					$comments_map['status'] = 1;
					$result['c_count'] = $m_cms_content_comments->where($comments_map)->count();
					$music_list[] = $result;
				}
				$echo['error_code'] = 1;
				$echo['data'] = $music_list;
			}else{
				$echo['error_code'] = -2;   //参数错误	
			}
			
			
		}else{
			$echo['error_code'] = -1;   //请求错误
		}
		#dump($echo);die;
		echo json_encode($echo);
	}
	
	#删除播放记录
	public function delete_play(){
		$m_cms_recently = M("cms_recently");
		if(IS_POST){
			
			#参数
			if($uid > 0 and $id > 0){
				$uid = I("param.uid");
				$id = I("param.id");
				$recently_map['r_id'] = $id;
				$recently_map['uid'] = $uid;
				$recently_map['type'] = 2;
				
				$recently_data['status'] = 0;
				$m_cms_recently->where($recently_map)->save($recently_data);
				
				$echo['error_code'] = 1;
			}else{
				$echo['error_code'] = -2;
			}
		
		}else{
			$echo['error_code'] = -1;
		}
		echo json_encode($echo);
		
		
	}
	
	public function ajax_shangchuan(){
		
		 header('content-type:text/html;charset:utf-8');
		 $m_common_upload_type = M("common_upload_type");
		 $m_common_upload = M("common_upload");
		 
		 $userid = getUID()?getUID():0;
		$dir_base = './upload/'.$userid.'/'.date('Y',time()).'/'.date('m',time()).'/'.date('d',time()).'/';
		$dir_bases = '/upload/'.$userid.'/'.date('Y',time()).'/'.date('m',time()).'/'.date('d',time()).'/';
		//$dir_base = "./files/";     //文件上传根目录
		//没有成功上传文件，报错并退出。
		$output = "<textarea>";
		$index = 0;        //$_FILES 以文件name为数组下标，不适用foreach($_FILES as $index=>$file)
		
		
		foreach($_FILES as $file){
			$upload_file_name = 'upload_file' . $index;        //对应index.html FomData中的文件命名
			
			$filename_array = explode(".",$_FILES[$upload_file_name]['name']);
			/* $this->ajaxReturn($upload_file_name); */
			$filename = uniqid($index).'.'.$filename_array[1];
			//filename
			$filename_save = $_FILES[$upload_file_name]['name'];
			
		
			$gb_filename = iconv('utf-8','gb2312',$filename);    //名字转换成gb2312处理
				
			//文件不存在才上传
			/* var_dump($dir_bases);
			var_dump($gb_filename);
			var_dump(file_exists($dir_bases.$gb_filename));die; */
			if(!file_exists($dir_base.$gb_filename)) {
				
				if (! file_exists ( $dir_base )) {
					mkdir ( "$dir_base", 7777, true );
				}
				$isMoved = false;  //默认上传失败
				$MAXIMUM_FILESIZE = 20 * 1024 * 1024;     //文件大小限制    1M = 1 * 1024 * 1024 B;
				$rEFileTypes = "/^\.(jpg|jpeg|gif|png|mp3|lrc){1}$/i"; 
				
				if ($_FILES[$upload_file_name]['size'] <= $MAXIMUM_FILESIZE && preg_match($rEFileTypes, strrchr($gb_filename, '.'))) {
					$isMoved = @move_uploaded_file ( $_FILES[$upload_file_name]['tmp_name'], $dir_base.$gb_filename);        //上传文件
				}
			}else{
				$isMoved = true;    //已存在文件设置为上传成功
			}
			
			if($isMoved){
				//输出图片文件<img>标签
				//注：在一些系统src可能需要urlencode处理，发现图片无法显示，
				//请尝试 urlencode($gb_filename) 或 urlencode($filename)，不行请查看HTML中显示的src并酌情解决。
				$output .= "<img src='{$dir_bases}{$filename}' title='{$filename}' alt='{$filename}'/>";
				$img_src[$index]['url'] = $dir_bases.$filename;
				$img_src[$index]['size'] = $_FILES[$upload_file_name]['size'];
				
				#上传类型
				$cutmap['title'] = $filename_array[1];
				$cutdata = $m_common_upload_type->where($cutmap)->find();
				if($cutdata){
					$cuttype = $cutdata['id'];
				}else{
					$cutsdata['title'] = "$filename_array[1]";
					$cutsdata['status'] = 1;
					$cuttype = $m_common_upload_type->add($cutsdata);
				}
				
				$cudata =array(
					'status'=>1,
					'url'=> $dir_bases.$filename,
					'title'=>$filename,
					'original'=>$filename_save,
					'type'=>$cuttype,
					'size'=>$_FILES[$upload_file_name]['size'],
					'time'=>time(),
					'uid'=>$userid,
					
				);
				//var_dump($cudata);exit;
				$m_common_upload->add($cudata);
			}else {
				//上传失败则把error.jpg传回给前端
				//$output .= "<img src='{$dir_base}error.jpg' title='{$filename}' alt='{$filename}'/>";
				//$img_src[] = $dir_bases.$dir_base.'error.jpg';
			}
			$index++;
		}
		#echo $output."</textarea>";
		$this->ajaxReturn($img_src);
	}
	
	
	#出售(专辑详情)
	public function chu_album(){
		$m_mall_content = M("mall_content");
		if(IS_POST){
			$id = I("param.id");
			$uid = I("param.uid");
			$map['id'] = $id;
			$map['uid'] = $uid;
			$map['status'] = 2;
			$map['type'] = 16;
			$data = $m_mall_content->where($map)->field("id,name,img,singer,isrc,intro,money,inventory")->find();
			
			if($data){
				$data['img'] = if_url($data['img']);
				$info = 1;   
				$echo['data'] = $data;				
			}else{
				$info = -2;   //不能出售
			}
		}else{
			$info = -1;    //请求错误
		}
		$echo['error_code'] = $info;
		#dump($echo);die;
		echo json_encode($echo);
	}
	
	
	#进行出售操作
	public function chu_albums(){
		$m_mall_content = M("mall_content");
		
		if(IS_POST){
		#参数
		$id = I("param.id");    #1077
		$uid = I("param.uid");   #58
		$count = I("param.count");    #100
		$money = I("param.money");     #0.01
		
		$map['id'] = $id;
		$map['uid'] = $uid;
		$map['status'] = 2;
		$map['type'] = 16;
		$data = $m_mall_content->where($map)->field("id")->find();
		if($data){
			$save_map['id'] = $id;
			$save_map['uid'] = $uid;
			$save_map['type'] = 16;
			$save_map['status'] = 2;
			$save_data['status'] = 3;
			$save_data['inventory'] = $count;
			$save_data['money'] = $money;
			
			$result = $m_mall_content->where($save_map)->save($save_data);
			if($result){
				$info = 1;   //(发起审核)
			}else{
				$info = -3;     //出售失败，重新出售
			}
		}else{
			$info = -2;      //不能出售
		}
		}else{
			$info = -1;    //请求错误
		}
		$echo['error_code'] = $info;
		echo json_encode($echo);
		
	}
	
	#转售(专辑详情)
	public function zhuan_album(){
		$m_mall_content = M("mall_content");
		if(IS_POST){
			$id = I("param.id");
			$uid = I("param.uid");
			$map['id'] = $id;
			$map['uid'] = $uid;
			$map['status'] = 2;
			$map['type'] = 22;
			$data = $m_mall_content->where($map)->field("id,name,img,singer,isrc,intro,original_money")->find();
			
			if($data){
				$data['img'] = if_url($data['img']);
				$info = 1;
				$echo['data'] = $data;
			}else{
				$info = -2;   //不能出售
			}
		}else{
			$info = -1;    //请求错误
		}
		$echo['error_code'] = $info;
		#dump($echo);die;
		echo json_encode($echo);
	}
	
	#转售提交操作
	public function zhuan_albums(){
		$m_mall_content = M("mall_content");
		if(IS_POST){
			$id = I("param.id");
			$uid = I("param.uid");
			$money = I("param.money");
			#$money = 0.02;
		
			$map['id'] = $id;
			$map['uid'] = $uid;
			$map['status'] = 2;
			$map['type'] = 22;
			$data = $m_mall_content->where($map)->field("id")->find();
			if($money >= $data['original_money']){
				if($data){
					$save_map['id'] = $id;
					$save_map['uid'] = $uid;
					$save_map['type'] = 22;
					$save_map['status'] = 2;
					$save_data['status'] = 1;
					$save_data['inventory'] = 1;
					$save_data['sale'] = 0;
					$save_data['money'] = $money;
					
					$result = $m_mall_content->where($save_map)->save($save_data);
					if($result){
						$info = 1;   //发起转售
					}else{
						$info = -3;     //出售失败，重新出售
					}
				}else{
					$info = -2;   //不能出售
				}
			}else{
				$info = -4;    //价格不能低于购买价格
			}
			
		}else{
			$info = -1;    //请求错误
		}
		$echo['error_code'] = $info;
		#dump($echo);die;
		echo json_encode($echo);
	}
	
	#消息通知
	public function notice(){
		$m_cms_message = M("cms_message");
		
		$map['status'] = array('in','1,2');
		$list = $m_cms_message->where($map)->field("value,time")->order("time desc")->limit(15)->select();
		foreach($list as $i=>$v){
			$list[$i]['time'] = date("Y-m-d H:i",$list[$i]['time']);
		}
		$echo['error_code'] = 1;
		$echo['data'] = $list;
		#dump($echo);die;
		echo json_encode($echo);
		
	}
	
	
	/* 音乐人推荐 */
	public function user_tui(){
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		$m_cms_style = M('cms_style');
		if(IS_POST){
			#查询用户偏好
			$uid = I('param.uid');   //用户id
			if($uid > 0){
				$user_style_str = user_style($uid);
				#查询该偏好下的推荐专辑
				$tuijian_map['style_id'] = array('in',$user_style_str);
				$tuijian_map['style_table'] = 5;      //表示专辑
				$tuijian_list = $m_cms_style->field('music_id')->where($tuijian_map)->select();
				#改为一维数组并且去重
				$tuijian_array = array_column($tuijian_list,'music_id');
				$tuijian_array = array_unique($tuijian_array);
				$tuijian_str = implode(',',$tuijian_array);
				#根据偏好查询出来的专辑 
				$tuijian_str_map['id'] = array('in',$tuijian_str);
			}
			$tuijian_str_map['status'] = 1;
			$tuijian_str_map['recommended'] = 1;
			$tuijian_str_map['group_id'] = 9;
			$tuijian_str_list = $m_common_user->where($tuijian_str_map)->field("img,nickname,id")->order("sort desc")->limit(10)->select();
			
			#dump($tuijian_str_list);die;
			
			foreach($tuijian_str_list as $i=>$v){
				#判断是否是授权   授权的头像了路径不改变
				$tuijian_str_list[$i]['img'] = if_url($tuijian_str_list[$i]['img']);
				
			}
			
			#img封面图  name名称  id主键    songs_count歌曲个数
			$echo['error_code'] = 1;
			$echo['data'] = $tuijian_str_list;
			#dump($echo);die;
			$echo_str = json_encode($echo);
			echo $echo_str;
		}else{
			$echo['error_code'] = 0;
			$echo_str = json_encode($echo);
			echo $echo_str;
		}
	}
	 
	#我的热度数据
	public function my_ranking(){
		
		$m_common_user = M("common_user");
		if(IS_POST){
			$uid = I("param.uid");
			#$uid = 46;
			$map['id'] = $uid;
			$map['group_id'] = 9;
			$map['status'] = 1;
			$data = $m_common_user->where($map)->field("id,votes,img")->find();
			$data['num_votes'] = jindu_num($data['votes']);
			if($data){
				#判断是否是授权   授权的头像了路径不改变
				$data['img'] = if_url($data['img']);
				
				#求取排名
				$paiming_map['votes'] = array('gt',$data['votes']);
				$paiming_map['status'] = 1;
				$paiming_map['group_id'] = 9;
				$paiming_count = $m_common_user->where($paiming_map)->field('id')->count();
				
				#热度排行榜
				
				$paimings_map['status'] = 1;
				$paimings_map['group_id'] = 9;
				$paiming_list = $m_common_user->where($paimings_map)->field('id,nickname,img,votes')->select();
				
				foreach($paiming_list as $i=>$v){
					#判断是否是授权   授权的头像了路径不改变
						$paiming_list[$i]['img'] = if_url($paiming_list[$i]['img']);
					
				}
				
				$echo['error_code'] = 1;
				$echo['user'] = $data;
				$echo['paihang'] = $paiming_list;
			}else{
				$echo['error_code'] = -2;    //参数错误
			}
		}else{
			$echo['error_code'] = -1;    //请求错误
		}
		#dump($echo);
		echo json_encode($echo);
	}
	
	#专辑收藏量排行  20个
	public function collection_ranking(){
		$m_mall_content = M("mall_content");
		
		$map['type'] = 16;
		$map['status'] = 1;
		$list = $m_mall_content->where($map)->field("id,name,img,intro,album_collection")->order("album_collection desc")->limit(20)->select();
		foreach($list as $i=>$v){
			$list[$i]['img'] = if_url($list[$i]['img']);
		}
		
		$echo['error_code'] = 1;
		$echo['data'] = $list;
		#dump($echo);die;
		echo json_encode($echo);
	}
	
	
	#赠与
	public function zengyu(){
		$m_mall_content = M("mall_content");
		$m_mall_content_zengyu = M("mall_content_zengyu");
		$m_common_user = M("common_user");
		if(IS_POST){
			
		
		$uid = I("param.uid");
		$goods_id = I("param.goods_id");
		$tel = I("param.tel");
		
		$user_map['tel'] = $tel;
		$user_map['status'] = 1;
		$user_data = $m_common_user->where($user_map)->find();
		
		if($user_data){
			$map['uid'] = $uid;
			$map['id'] = $goods_id;
			$map['type'] = 22;
			$map['status'] = 2;
			$data = $m_mall_content->where($map)->find();
			#查询赠与之人有没有该专辑，有则不能赠与，没有则赠与
			$if_map['isrc'] = $data['isrc'];
			$if_map['uid'] = $user_data['id'];
			$if_data = $m_mall_content->where($if_map)->find();
			if($if_data){
				#有则不能赠与
				$info = -4;      //有，不能赠与
			}else{
				#没有则赠与
				if($data){
				$z_uid['uid'] = $user_data['id'];
				$result = $m_mall_content->where($map)->save($z_uid);
					if($result){
						#记录
						$zengyu_data['uid'] = $uid;
						$zengyu_data['zid'] = $user_data['id'];
						$zengyu_data['time'] = time();
						$zengyu_data['ip'] = get_client_ip();
						$m_mall_content_zengyu->add($zengyu_data);
						$info = 1;      //成功
					}else{
						$info = -5;     //赠与失败，
					}
				}else{
					$info = -2;     //当前专辑不允许赠与
				}
			}
			
			
		}else{
			$info = -3;     //赠与用户不存在
		}
		
		
		}else{
			$info = -1;     //请求错误
		}
		$echo['error_code'] = $info;
		echo json_encode($echo);
	}
	
	
	#分类下随机选歌
	public function suiji_song(){
		$m_mall_content = M("mall_content");
		$m_mall_content_img = M("mall_content_img");
		if(IS_POST){
			$style = I("param.style");
			$uid = I("param.uid");
			$map['style'] = array("like","%$style%");
			$map['type'] = 15;
			$map['status'] = 1;
			$list = $m_mall_content->where($map)->field("id")->select();
			
			$list = array_column($list,'id');
			$list_count = count($list);
			if($list_count>10){
				$list_count = 10;
			}
			$suiji_list = array_rand($list,$list_count);
			#$s_list = song_detail($list,$uid);
			foreach($suiji_list as $i=>$v){
				$s_map[] = $list[$suiji_list[$i]];
				/* $s_data = $m_mall_content->where($s_map)->field("id,name,singer")->find();
				
				$xuanze_img_map['type'] = 1;					
				$xuanze_img_map['form_id'] = $s_data['id'];
				$xuanze_img_data = $m_mall_content_img->where($xuanze_img_map)->order("employ desc")->find();
				$s_data['img'] =  if_url($xuanze_img_data['url']);
				
				
				$s_list[] = $s_data; */
			}
			#dump($s_map);die;
			$s_list = song_detail($s_map,$uid);
			$echo['error_code'] = 1;
			$echo['data'] = $s_list;
		}else{
			$echo['error_code'] = 0;
			$echo['data'] = array();
		}
		#dump($echo);die;
		echo json_encode($echo);
		
	}
	
	
	#提现
	public function tixian(){
		$m_mall_order = M("mall_order");
		$m_cms_tixian = M("cms_tixian");
		$m_common_user = M("common_user");
		
		$uid = I("param.uid");
		$money = I('param.money');
		
		$day = date("w");
		$d_map['week'] = $day;
		$d_map['type'] = 2;
		$d_data = $m_cms_tixian->where($d_map)->select();
		if($d_data){
			#不是冻结日
			
			#判断余额
			$u_map['id'] = $uid;
			$u_data = $m_common_user->where($u_map)->find();
			if($u_data['pay_way'] == '' or $u_data['pay_name'] == ''){
				if($u_data['money'] >= $money){
					#生成订单
					$map['today'] = getToday();
					$num = $m_mall_order->where($map)->count();
					
					$t_map['order_type'] = 5;
					$t_map['uid'] = $uid;
					$t_map['order_id'] = date('ymd',time()).sprintf("%06d",$num+1);
					$t_map['name'] = "提现";
					$t_map['pay_type'] = 3;
					$t_map['money'] = $money;
					$t_map['spending'] = 1;
					$t_map['consignee'] = $u_data['pay_way'];
					$t_map['client_name'] = $u_data['pay_name'];
					$t_map['tel'] = $u_data['tel'];
					$t_map['time'] = time();
					$t_map['today'] = getToday();
					$t_map['ip'] = get_client_ip();
					$t_map['status'] = 2;
					
					$result = $m_mall_order->add($t_map);
					if($result){
						#扣除余额
						$m_common_user->where($u_map)->setDec("money",$money);
						
					}
					
					$info = 1;    //提现成功
				}else{
					
					$info = -3;    // 余额不足
				}
			}else{
				$info = -4;      //请完善支付宝账号或者认证信息
			}
			
			
			
		}else{
			#冻结日
			$info = -2;    //冻结日不能体现
		}
		$echo['error_code'] = $info;
		echo json_encode($echo);
	}
	
	#反馈
	public function fankui_add(){
		$m_cms_message = M("cms_message");
		if(IS_POST){
			$value = I('param.value');
			$uid = I('param.uid');
			
			$map['type'] = 3;
			$map['status'] = 1;
			$map['uid'] = $uid;
			$map['value'] = $value;
			$map['time'] = time();
			$result = $m_cms_message->add($map);
			$info = $result?1:0;
		}else{
			$info = -1;
		}
		$echo['error_code'] = $info;
		echo json_encode($echo);
	}
	
	
	#设置
	public function shezhi(){
		$m_cms_message = M('cms_message');
		if(IS_POST){
			$map['id'] = I("param.id");
			$map['type'] = 5;
			$result = $m_cms_message->where($map)->field("value,time")->find();
			$yuming = "http://".$_SERVER['HTTP_HOST'].'/upload/';
			$result['value'] = str_ireplace('/upload/',$yuming,$result['value']);
			$result['time'] = date("Y-m-d H:i",$result['time']);
			$echo['error_code'] = 1;
			$echo['data'] = $result;
			#dump($echo);die;
		}else{
			$echo['error_code'] = 0;
			$echo['data'] = array();
		}
		echo json_encode($echo);
		
	}
	
	public function my_album(){
		
		$m_mall_content = M("mall_content");
		if(IS_POST){
			$uid = I('param.uid');
			#$uid = 1;
			if($uid){
				
				#我创建的专辑
				$map['status'] = array('in','1,2,3,4,5');
				$map['type'] = get_mall_model_conf('MALL_ALBUM');
				$map['uid'] = $uid;
				$list = $m_mall_content->where($map)->order('time desc')->field("img,id,name,money,singer,sale,inventory,status")->select();
				
				foreach($list as $i=>$v){
					$list[$i]['img'] = if_url($list[$i]['img']);
				}
				
				/* #我购买的专辑 
				$my_map['status'] = array('in','1,2');   //出售中  已出售
				$my_map['type'] = 22;
				$my_map['uid'] = $uid;
				$my_list = $m_mall_content->where($my_map)->order('time desc')->field("img,id,name,singer")->select();
				
				#合并两个数组
				$list = array_merge((array)$my_list,(array)$list);
				foreach($list as $i=>$v){
					$list[$i]['img'] = "http://".$_SERVER['HTTP_HOST'].$list[$i]['img'];
					$songs_map['form_id'] = $list[$i]['id'];
					$songs_map['type'] = 17;
					$songs_map['status'] = 1;
					$list[$i]['songs_count'] = $m_mall_content->where($songs_map)->count();
				}	 */
			}
			$echo['error_code'] = 1;
			$echo['data'] = $list;
			#dump($echo);die;
			$echo_str = json_encode($echo);
			echo $echo_str;
		}else{
			$echo['error_code'] = 0;
			$echo_str = json_encode($echo);
			echo $echo_str;
		}
	}
	
	public function qiniu(){
		$m_log = M("log");
		$data['value'] = json_encode(I());
		$m_log->add($data);
		
	}
	
	#歌单列表
	public function gedan_list(){
		$m_mall_content = M("mall_content");
		$m_mall_content_img = M("mall_content_img");
		$m_mall_content_music = M("mall_content_music");
		
		$uid = I("param.uid");
		#$uid = 1;
		$map['id'] = I("param.id");
		#$map['id'] = 1175;
		$value_data = $m_mall_content->where($map)->field("value")->find();
		$value_list = explode(",",$value_data['value']);
		if($value_list[0] != ''){
			$gedan_list = song_detail($value_list,$uid);
		}
		
		/* foreach($value_list as $i=>$v){
			$song_map['id'] = $value_list[$i];
			$song_map['status'] = 1;
			$song_data = $m_mall_content->where($song_map)->field("id,name,singer,value,mp3,foil_img")->find();
			
			$song_data['value'] = if_url($song_data['value']);
			$song_data['foil_img'] = if_url($song_data['foil_img']);
			$song_data['mp3'] = if_url($song_data['mp3']);
			#封面图
			if($song_data){
				$xuanze_img_map['type'] = 1;					
				$xuanze_img_map['form_id'] = $value_list[$i];
				$xuanze_img_data = $m_mall_content_img->where($xuanze_img_map)->order("employ desc")->find();
				$song_data['img'] = if_url($xuanze_img_data['url']);
				
				#判断是否是独家以及是否是超品
				$hq_dujia_array = if_hq_dujia($value_list[$i]);
				$song_data['if_hq'] = $hq_dujia_array['if_hq'];
				$song_data['if_dujia'] = $hq_dujia_array['if_dujia'];	
				
				#四个品质   type  1无损   2超品  3高品  4流畅
				$music_map['form_id'] = $value_list[$i];
				$hq_list = $m_mall_content_music->where($music_map)->order("type asc")->field("type,url")->select();
				$song_data['hq_list'] = $hq_list;
				
				$gedan_list[] = $song_data;
			}
				
		} */
		
		$echo['error_code'] = 1;
		$echo['data'] = $gedan_list;
		#dump($gedan_list);die;
		echo json_encode($echo);
		
	}
	
	
}